import { config } from '../config.js';
import { HTTP } from '../utils/http.js';
import { localStorage } from '../utils/storage.js';

const app = getApp();
const data = {
    page: 1
};
const _localStorage = new localStorage();

export class HomeModel extends HTTP {
    // 在招职位数据
    requestData() {
        return this.request({
            url: 'app/listRecruitment',
            data: {
                compId: config.COMP_ID,
                page: 1,
                limit: 10
            }
        })
    }
    // 企业数据
    compInfo() {
        return this.request({
            url: 'app/comp',
            data: {
                compId: config.COMP_ID
            }
        })
    }
    // 下拉刷新
    downRequestData() {
        return this.request({
            url: 'app/listRecruitment',
            data: {
                compId: config.COMP_ID,
                page: ++ data.page,
                limit: 10
            }
        })
    }
    // 职位详情
    jobDetails(rid) {
        return this.request({
            url: 'app/recruitment',
            data: {
                recruitmentId: rid
            }
        })
    }
    // 获取用户收藏的职位
    getAllLive() {
        return this.request({
            url: 'app/getPositionIdList',
            data: {
                openid: app.getOpenId()
            }
        })
    }
    // 收藏
    lives(rid) {
       return this.request({
            url: 'app/collerctionPosition',
            data: {
                openid: app.getOpenId(),
                recruitmentId: rid
            }
       })
    }
    // 取消收藏
    unLives(rid) {
        return this.request({
            url: 'app/cancelCollection',
            data: {
                openid: app.getOpenId(),
                recruitmentId: rid
            }
        })
    }
    // 投递简历
    deliveryResume(rid) {
        return this.request({
            url: 'app/deliveryResume',
            data: {
                recruitmentId: rid,
                openId: app.getOpenId()
            }
        })
    }
}